package com.cxyd.modules.wcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cxyd.common.constant.RcsConstants;
import com.cxyd.common.constant.WcsConstants;
import com.cxyd.common.service.impl.CrudServiceImpl;
import com.cxyd.modules.api.dto.RcsResultHK;
import com.cxyd.modules.log.service.SysLogWorkService;
import com.cxyd.modules.wcs.dao.AgvCallbackHkDao;
import com.cxyd.modules.wcs.dto.AgvCallbackHkDTO;
import com.cxyd.modules.wcs.entity.*;
import com.cxyd.modules.wcs.service.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

@Service
public class AgvCallbackHkServiceImpl extends CrudServiceImpl<AgvCallbackHkDao, AgvCallbackHkEntity, AgvCallbackHkDTO> implements AgvCallbackHkService {
    @Resource
    private AgvTrkHkService hkService;
    @Resource
    private TrkService trkService;
    @Resource
    private PlcItemService plcItemService;
    @Resource
    private PcItemService pcItemService;
    @Resource
    private StnMappingService stnMappingService;
    @Resource
    private SysLogWorkService logWorkService;

    @Override
    public QueryWrapper<AgvCallbackHkEntity> getWrapper(Map<String, Object> params) {
        return null;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public RcsResultHK callbackHandle(AgvCallbackHkDTO dto) {
        String reqCode = dto.getReqCode();
        String taskCode = dto.getTaskCode();
        String robotCode = dto.getRobotCode();
        String method = dto.getMethod();
//        当前站点信息
        String positionCode = dto.getCurrentPositionCode();
//        根据taskCode获取任务信息
        AgvTrkHkEntity task = hkService.getAgvTrkByTaskCode(taskCode);
        if (task == null) {
//            任务不存在不处理即可
            return new RcsResultHK().success(reqCode);
        }
//        记录车号
        task.setAgvCode(robotCode);
//        记录当前站点
        task.setCurrentPositionCode(positionCode);
//        不同的method调用不同的处理逻辑
        if (RcsConstants.HK_METHOD_START.equals(method)) {
//            1.任务开始(更新任务当前状态0-初始 1-任务下发 2-任务开始 3-搬送中 4-任务完成 9-任务取消)
            agvTrkStart(task);
        } else if (RcsConstants.HK_METHOD_OUTBIN.equals(method)) {
//            2.走出储位(可认为是下架)
            agvTrkOutbin(task, positionCode);
        } else if (RcsConstants.HK_METHOD_LOAD.equals(method)) {
//            3.AGV-LOAD申请(请求上料)
            agvTrkApplyLoad(task, positionCode);
        } else if (RcsConstants.HK_METHOD_ARRIVED.equals(method)) {
//            5.AGV-到达安全交互外侧位置
            agvTrkApplyArrived(task, positionCode);
        } else if (RcsConstants.HK_METHOD_UNLOAD.equals(method)) {
//            6.AGV-下料请求（下料架请求）
            agvTrkUnloadRequest(task, positionCode);
        } else if (RcsConstants.HK_METHOD_UNLOAD_DONE.equals(method)) {
//            6.AGV-下料完成（放下料架）
            agvTrkUnLoadDone(task, positionCode);
        } else if (RcsConstants.HK_METHOD_UNLOAD_JERRY.equals(method)) {
//            6.AGV-下料完成（放下料架）
            agvTrkUnLoadJerry(task, positionCode);
        } else if (RcsConstants.HK_METHOD_LEAVE.equals(method)) {
//            7.AGV-顶起料架后申请离开
            agvTrkApplyLeave(task, positionCode);
        } else if (RcsConstants.HK_METHOD_LEAVE_JERRY.equals(method)) {
//            7.AGV-顶起料架后申请离开
            agvTrkLeaveJerry(task, positionCode);
        } else if (RcsConstants.HK_METHOD_LEAVE_3F.equals(method)) {
//            7.AGV-顶起料架后申请离开(3F临时逻辑)
            agvTrkLeave3F(task, positionCode);
        } else if (RcsConstants.HK_METHOD_END.equals(method)) {
//            7.AGV-顶起料架后申请离开
            agvTrkEnd(task, positionCode);
        } else {

        }
        return new RcsResultHK().success(reqCode);
    }

    /***
     * 任务开始(步骤1)
     * @param task
     */
    private void agvTrkStart(AgvTrkHkEntity task) {
        String workName = "[流程-开始搬运]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkStart";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "任务单[" + task.getTaskCode() + "]收到[start]通知,小车[" + task.getAgvCode() + "]开始作业!";
//        start时并未执行该任务,只是说CTU接到有任务而已
        task.setStatus(RcsConstants.HK_STATUS_START);
        task.setData("start");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        找到对应[wcs_trk]任务进行更新
        TrkEntity trkEntity = trkService.selectById(task.getTrkId());
        if (trkEntity != null) {
            trkEntity.setComments(msg);
            trkEntity.setUpdater(WcsConstants.WCS_USER_ID);
            trkEntity.setUpdateDate(new Date());
            trkService.updateById(trkEntity);
        }
//        以料箱维度记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    /***
     * 走出储位（一般为出库下架）
     * @param task
     */
    private void agvTrkOutbin(AgvTrkHkEntity task, String positionCode) {
//        通知wms料箱已下架等
        String workName = "[流程-下料通知]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkOutbin";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "小车[" + task.getAgvCode() + "]将站点[" + positionCode + "]料架取出!";

//        更新任务状态
        task.setStatus(RcsConstants.HK_STATUS_TAKE); //任务状态
        task.setData("叉车已取出料架!");
        task.setUpdateDate(new Date());
        hkService.updateById(task);

        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    /***
     * Arrived申请（外卡控）
     * @param task
     */
    private void agvTrkApplyArrived(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-到位请求]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkApplyArrived";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "[" + task.getAgvCode() + "]号车在[" + positionCode + "]进行[Arrived]申请!";
//        获取安全交互卡控点(Arrived对应外卡控站点)
        StnMappingEntity extStn = stnMappingService.getStnByNo(positionCode);
        if (extStn == null) {
//            站点未配置
            code = "ArrivedError_001";
            msg = msg + "外卡控站点[" + positionCode + "]未配置!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        匹配主任务（主要是看任务中的空满标记）
        TrkEntity wcsTrk = trkService.selectById(task.getTrkId());
        if (wcsTrk == null) {
//            站点未配置
            code = "ArrivedError_002";
            msg = msg + "无关联主任务!ID为[" + task.getTrkId() + "]!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        空车Arrived=1,满载Arrived=2
        pcItemService.updateValueByNo(extStn.getTargetAgv(), wcsTrk.getIsFull());
        msg = msg + "外卡控[" + extStn.getTargetAgv() + "]写入信号[" + wcsTrk.getIsFull() + "]!";
        wcsTrk.setCurPos(positionCode);
        wcsTrk.setComments(msg);
        wcsTrk.setUpdateDate(new Date());
        trkService.updateById(wcsTrk);
        task.setStatus(RcsConstants.HK_STATUS_ARRIVED); //任务状态
        task.setData("Arrived");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    /***
     * AGV-LOAD申请(取料)
     * @param task
     */
    private void agvTrkApplyLoad(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-申请上料]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkApplyLoad";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "[" + task.getAgvCode() + "]号车在[" + positionCode + "]进行[LoadRequest]申请!";
//        获取当前站点对应的机台编号
        StnMappingEntity interStn = stnMappingService.getStnByNo(positionCode);
        if (interStn == null) {
            //            站点未配置
            code = "LoadError_001";
            msg = msg + "站点[" + positionCode + "]未配置!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }

        //        匹配主任务
        TrkEntity wcsTrk = trkService.selectById(task.getTrkId());
        if (wcsTrk == null) {
//            站点未配置
            code = "LoadError_002";
            msg = msg + "无关联主任务!ID为[" + task.getTrkId() + "]!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        与机台进行安全交互(向pc_item表中写入对应机台内卡控状态-到达无货)
        pcItemService.updateValueByNo(interStn.getTargetAgv(), wcsTrk.getIsFull());
        msg = msg + "内卡控[" + interStn.getTargetAgv() + "]写入信号[" + wcsTrk.getIsFull() + "]!";
//        更新主任务信息（上料成功后isFull字段置为2）
        wcsTrk.setIsFull(RcsConstants.AGV_STATION_STATUS_FULL);
        wcsTrk.setComments(msg);
        wcsTrk.setUpdateDate(new Date());
        trkService.updateById(wcsTrk);
//        更新任务状态
        task.setStatus(RcsConstants.HK_STATUS_LOAD); //任务状态
        task.setData("LoadRequest");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    private void agvTrkUnloadRequest(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-下料请求]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkUnloadRequest";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "[" + task.getAgvCode() + "]号车在[" + positionCode + "]进行[UnloadRequest]申请!直接任务继续";
//        同时补充资料信息
        task.setStatus(RcsConstants.HK_STATUS_CONTINUE); //任务状态
        task.setData("UnloadRequest");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    /***
     * AGV-UNLOAD申请(放料完成)
     * @param task
     */
    private void agvTrkUnLoadDone(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-下料完成]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkUnLoadDone";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "[" + task.getAgvCode() + "]号车在[" + positionCode + "]进行[UnloadDone]申请!";
//        根据当前位置获取一下站台对应的站点(内卡控)
        StnMappingEntity interStn = stnMappingService.getStnByNo(positionCode);
        if (interStn == null) {
            code = "UnloadDone_001";
            msg = msg + "站点[" + positionCode + "]未配置!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        如果是电梯需要做特殊处理（临时方案!后期需要调整回来）
        String itemNo = interStn.getTargetAgv();
        String contType = interStn.getContType();

        //        匹配主任务
        TrkEntity wcsTrk = trkService.selectById(task.getTrkId());
        if (wcsTrk == null) {
//            站点未配置
            code = "UnloadDone_002";
            msg = msg + "无关联主任务!ID为[" + task.getTrkId() + "]!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        与机台进行安全交互(向pc_item表中写入对应机台内卡控状态-到达有货)
        pcItemService.updateValueByNo(itemNo, wcsTrk.getIsFull());
        msg = msg + "内卡控[" + itemNo + "]写入信号[" + wcsTrk.getIsFull() + "]!";
//        同时补充资料信息
        pcItemService.updateValueByNo(contType, wcsTrk.getContType());
//        更新主任务信息（下料成功后isFull字段置为1）
        wcsTrk.setIsFull(RcsConstants.AGV_STATION_STATUS_EMPTY);
        wcsTrk.setComments(msg);
        wcsTrk.setUpdateDate(new Date());
        trkService.updateById(wcsTrk);
        task.setStatus(RcsConstants.HK_STATUS_UNLOAD_DONE); //任务状态
        task.setData("UnloadDone");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    /***
     * AGV-UNLOAD申请(放料完成)
     * @param task
     */
    private void agvTrkUnLoadJerry(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-Jerry下料]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkUnLoadJerry";
        String code = WcsConstants.PROC_CODE_SUCCESS;

        positionCode = positionCode.replace("X", "");

        String msg = "[" + task.getAgvCode() + "]号车在[" + positionCode + "]进行[UnloadJerry]申请!";
//        根据当前位置获取一下站台对应的站点(内卡控)
        StnMappingEntity interStn = stnMappingService.getStnByNo(positionCode);
        if (interStn == null) {
            code = "UnloadJerry_001";
            msg = msg + "站点[" + positionCode + "]未配置!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        如果是电梯需要做特殊处理（临时方案!后期需要调整回来）
        String itemNo = interStn.getTargetAgv();
        String contType = interStn.getContType();

        //        匹配主任务
        TrkEntity wcsTrk = trkService.selectById(task.getTrkId());
        if (wcsTrk == null) {
//            站点未配置
            code = "UnloadJerry_002";
            msg = msg + "无关联主任务!ID为[" + task.getTrkId() + "]!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        与机台进行安全交互(向pc_item表中写入对应机台内卡控状态-到达有货)
        pcItemService.updateValueByNo(itemNo, wcsTrk.getIsFull());
        msg = msg + "内卡控[" + itemNo + "]写入信号[" + wcsTrk.getIsFull() + "]!";
//        同时补充资料信息
        pcItemService.updateValueByNo(contType, wcsTrk.getContType());
//        更新主任务信息（下料成功后isFull字段置为1）
        wcsTrk.setIsFull(RcsConstants.AGV_STATION_STATUS_EMPTY);
        wcsTrk.setComments(msg);
        wcsTrk.setUpdateDate(new Date());
        trkService.updateById(wcsTrk);
        task.setCurrentPositionCode(positionCode);
        task.setStatus(RcsConstants.HK_STATUS_UNLOAD_DONE); //任务状态
        task.setData("UnloadJerry");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    private void agvTrkApplyLeave(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-离开请求]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkApplyLeave";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "[" + task.getAgvCode() + "]号小车在[" + positionCode + "]进行[Leave]申请";
//        在等待点申请离开
        StnMappingEntity extStn = stnMappingService.getStnByNo(positionCode);
        if (extStn == null) {
            code = "LeaveError_001";
            msg = msg + "站点[" + positionCode + "]未配置!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        匹配主任务
        TrkEntity wcsTrk = trkService.selectById(task.getTrkId());
        if (wcsTrk == null) {
//            站点未配置
            code = "LeaveError_002";
            msg = msg + "无关联主任务!ID为[" + task.getTrkId() + "]!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        向外卡控写入完成信号
        pcItemService.updateValueByNo(extStn.getTargetAgv(), "4");
        msg = msg + "外卡控[" + extStn.getTargetAgv() + "]写入信号[4]!";
        wcsTrk.setCurPos(positionCode);
        wcsTrk.setComments(msg);
        wcsTrk.setUpdateDate(new Date());
        trkService.updateById(wcsTrk);
        task.setStatus(RcsConstants.HK_STATUS_LEAVE); //任务状态
        task.setData("Leave!");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    private void agvTrkLeaveJerry(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-Jerry离开]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkLeaveJerry";
        String code = WcsConstants.PROC_CODE_SUCCESS;

        positionCode = positionCode + "X";

        String msg = "[" + task.getAgvCode() + "]号小车在[" + positionCode + "]进行[LeaveJerry]申请";
//        在等待点申请离开
        StnMappingEntity extStn = stnMappingService.getStnByNo(positionCode);
        if (extStn == null) {
            code = "LeaveJerryError_001";
            msg = msg + "站点[" + positionCode + "]未配置!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        匹配主任务
        TrkEntity wcsTrk = trkService.selectById(task.getTrkId());
        if (wcsTrk == null) {
//            站点未配置
            code = "LeaveJerryError_002";
            msg = msg + "无关联主任务!ID为[" + task.getTrkId() + "]!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        向外卡控写入完成信号
        pcItemService.updateValueByNo(extStn.getTargetAgv(), "4");
        msg = msg + "外卡控[" + extStn.getTargetAgv() + "]写入信号[4]!";
        wcsTrk.setCurPos(positionCode);
        wcsTrk.setComments(msg);
        wcsTrk.setUpdateDate(new Date());
        trkService.updateById(wcsTrk);
        task.setCurrentPositionCode(positionCode);
        task.setStatus(RcsConstants.HK_STATUS_LEAVE); //任务状态
        task.setData("LeaveJerry!");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    private void agvTrkLeave3F(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-离开请求]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkLeave3F";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "[" + task.getAgvCode() + "]号小车在[" + positionCode + "]进行[Leave3F]申请";
        //        根据当前位置获取一下站台对应的站点
        StnMappingEntity extStn = stnMappingService.getStnByNo(positionCode);
        if (extStn == null) {
//            站点未配置
            code = "LeaveError_001";
            msg = msg + "站点[" + positionCode + "]未配置!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
//        匹配主任务
        TrkEntity wcsTrk = trkService.selectById(task.getTrkId());
        if (wcsTrk == null) {
//            站点未配置
            code = "LeaveError_002";
            msg = msg + "无关联主任务!ID为[" + task.getTrkId() + "]!";
            logWorkService.workLogging(workName, task.getTaskCode(), code,
                    msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
            return;
        }
        pcItemService.updateValueByNo(extStn.getTargetAgv(), "4");
        wcsTrk.setComments(msg);
        wcsTrk.setUpdateDate(new Date());
        trkService.updateById(wcsTrk);
        //task.setStatus(RcsConstants.HK_STATUS_TAKE); //任务状态
        task.setData("Leave3F");
        task.setUpdateDate(new Date());
        hkService.updateById(task);
//        记录日志
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }

    /***
     * 任务结束(将对应agv搬送任务完成并转移历史)
     * @param task
     */
    private void agvTrkEnd(AgvTrkHkEntity task, String positionCode) {
        String workName = "[流程-任务结束]-HK";
        String workProc = "AgvCallbackHkServiceImpl.agvTrkEnd";
        String code = WcsConstants.PROC_CODE_SUCCESS;
        String msg = "小车[" + task.getAgvCode() + "]到达站点[" + positionCode + "],任务完成[End]通知!";

//      获取[wcs_trk]信息
        task.setStatus(RcsConstants.HK_STATUS_END); //任务完成
        task.setData("End!");
        task.setCurrentPositionCode(positionCode);
        task.setUpdateDate(new Date());
        hkService.updateById(task);
        TrkEntity trkEntity = trkService.selectById(task.getTrkId());
        if (trkEntity == null) {
            return;
        }
//        任务执行完成则需要清空PLC中的任务链信息
        PlcItemEntity taskInfo = plcItemService.getItemByUnitNo(trkEntity.getUnitNo(), trkEntity.getContNo());
        if (taskInfo != null) {
            pcItemService.updateValueByNo(taskInfo.getItemNo(), "0");
            msg = msg + "清除任务链[" + taskInfo.getItemNo() + "]信息";
        }
        trkEntity.setTrkSt(WcsConstants.TRK_STATUS_DONE);
        trkEntity.setComments(msg);
        trkEntity.setCurPos(positionCode);
        trkEntity.setUpdater(WcsConstants.WCS_USER_ID);
        trkEntity.setUpdateDate(new Date());
        trkService.updateById(trkEntity);
//        将AGV任务转移历史
        hkService.updateAgvTrkByTaskCode(task.getTaskCode());
//        将TRK数据也进行转移
        trkService.updateTrkByContNo(trkEntity.getContNo());
        logWorkService.workLogging(workName, task.getTaskCode(), code,
                msg, null, workProc, WcsConstants.WCS_USER_NAME, 10L);
    }
}
